package com.SpringBoot.cart.controller;


import com.SpringBoot.Util.Result;
import com.SpringBoot.cart.pojo.Cart;
import com.SpringBoot.cart.service.CartService;
import org.springframework.web.bind.annotation.*;

import org.springframework.stereotype.Controller;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author bxk
 * @since 2025-09-15
 */
@Controller
@RestController
@RequestMapping("/cart")
public class CartController {

    private final CartService cartService;

    public CartController(CartService cartService) {
        this.cartService = cartService;
    }

    @PostMapping("/addCart")
    public Result addCart(@RequestBody Cart cart) {
        return cartService.addCart(cart);
    }

    @PostMapping("/deletedCart")
    public Result deletedCart(@RequestBody Cart cart) {
        return cartService.deleteCart(cart);
    }

    @PostMapping("/updateCart")
    public Result updateCart(@RequestBody Cart cart) {
        return cartService.updateCart(cart);
    }

    @GetMapping("/selectByUserId")
    public Result selectByUserId(@RequestParam Integer userId) {
        return cartService.selectByUserId(userId);
    }



}
